import { request } from '@/utils/request'

const base = '/depts'

export function findDepts (key) {
  return request({
    url: base,
    method: 'get',
    params: {
      key
    }
  })
}

export function createDept (data,createRootDept=false) {
  return request({
    url: base,
    method: 'post',
    data,
    params:{
      createRootDept
    }
  })
}

export function deleteDept (deptId) {
  return request({
    url: `${base}/${deptId}`,
    method: 'delete'
  })
}

export function updateDept (data) {
  return request({
    url: `${base}/${data.id}`,
    method: 'patch',
    data
  })
}

export function findChildrenCustomers (customerCompanyId) {
  return request({
    url: `${base}/${customerCompanyId}/children`,
    method: 'get'
  })
}
